package com.medicine.product.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.medicine.product.entity.Student;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lynn
 * @version 1.0
 * @date 2022/1/18
 */
public class JsonTest {

    public static void main(String[] args) {

        List<Student> students = new ArrayList<>(16);
        students.add(new Student("1", "张三", 18, "male", 88));
        students.add(new Student("2", "李四", 17, "male", 60));
        students.add(new Student("3", "王五", 18, "male", 100));
        students.add(new Student("4", "赵六", 20, "male", 10));
        students.add(new Student("5", "董七", 14, "female", 95));
        students.add(new Student("6", "幺八", 21, "male", 55));
        students.add(new Student("7", "老九", 20, "female", 66));
        students.add(new Student("8", "小明", 18, "male", 100));
        students.add(new Student("9", "小红", 22, "female", 95));
        students.add(new Student("10", "小张", 25, "male", 90));

        String json = JSONArray.toJSONString(students);  //list 转json

        System.out.println(json);

        Student student =  new Student("10", "小高", 25, "male", 90);
        String json1 = JSON.toJSONString(student);
        System.out.println(json1);


    }
}
